package com.acwing.partition35;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/3/13 16:38
 */
public class AC3419双向排序_模拟 {

    private static final int N = 100010;
    private static int[] a = new int[N];
    private static int n, m;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        for (int i = 0; i < N; i++) a[i] = i;
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        while (m-- > 0) {
            ss = reader.readLine().split(" ");
            int op = Integer.parseInt(ss[0]), pos = Integer.parseInt(ss[1]);
            if (op == 0) {
                //a[1]到a[pos]降序排列
                Arrays.sort(a, 1, pos + 1);
                reverse(1, pos);
            } else {
                //a[pos]到a[n]升序排列
                Arrays.sort(a, pos, n + 1);
            }
        }
        for (int i = 1; i <= n; i++) writer.write(a[i] + " ");
        writer.flush();
    }

    private static void reverse(int l, int r) {
        while (l < r) {
            int t = a[l];
            a[l] = a[r];
            a[r] = t;
            l++;
            r--;
        }
    }
}
